/**
 * 本地存储.
 * @type {{STORE_KEY: string, load(): any, save(*): void, remove(): void}}
 */
const LocalStore = {
    /**
     * 保存数据.
     * @param key
     * @param data
     */
    save(key, data) {
        let store = {}
        store[key] = data
        chrome.storage.local.set(store, () => {
            console.log('save success')
        })
    },
    /**
     * 加载数据.
     * @param key
     * @param call
     * @returns {any}
     */
    get(key, call) {
        chrome.storage.local.get([key], (store) => {
            console.log('store', store)
            call(store[key])
        })
    },
    /**
     * 清除数据.
     * @param key
     */
    remove(key) {
        chrome.storage.local.remove([key], () => {})
    }
}

export { LocalStore}